package callingmechanism;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class MyBateToLongDecoder extends ByteToMessageDecoder {

    /* 解码方法
     * channelHandlerContext 上下文对象
     * byteBuf  入站的byteBuf对象
     * list 将解码后的数据传递给下一个hander
     * */
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
        System.out.println("调用解码方法 MyBateToLongDecoder decode");
        if (byteBuf.readableBytes() >= 8) {
            list.add(byteBuf.readLong());
        }
    }
}
